﻿using LRT.Engine;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Data;
using System.IO;

namespace LRT.Engine.Tests
{
    
    
    /// <summary>
    ///This is a test class for ResourceGeneratorTest and is intended
    ///to contain all ResourceGeneratorTest Unit Tests
    ///</summary>
    [TestClass()]
    public class ResourceGeneratorTets
    {

        private string _sourceFilePath = "MainForm.zh.resx";
        private string _targetFilePath = "MainForm.en.resx";

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for ResourceGenerator Constructor
        ///</summary>
        [TestMethod()]
        public void ResourceGeneratorConstructorTest()
        {
            string sourceFilePath = this._sourceFilePath;
            string targetCulture = "en";
            bool useTranslationMemory = false;
            bool useGoogleTranslate = false;
            try
            {
                ResourceGenerator target = new ResourceGenerator(sourceFilePath, targetCulture, useTranslationMemory, useGoogleTranslate);
                Assert.IsNotNull(target);
            }
            catch (System.Exception ex)
            {
                Assert.Fail(ex.Message);
                return;
            }
        }

        /// <summary>
        ///A test for GetSourceCulture
        ///</summary>
        [TestMethod()]
        public void GetSourceCultureTest()
        {
            string resourceFilePath = this._sourceFilePath;
            string expected = "zh";
            string actual;
            actual = ResourceGenerator.GetSourceCulture(resourceFilePath);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Save
        ///</summary>
        [TestMethod()]
        public void SaveTest()
        {
            string sourceFilePath = this._sourceFilePath;
            string targetCulture = "en";
            bool useTranslationMemory = false;
            bool useGoogleTranslate = false;
            ResourceGenerator target = new ResourceGenerator(sourceFilePath, targetCulture, useTranslationMemory, useGoogleTranslate); // TODO: Initialize to an appropriate value
            target.Save();
            bool fileCreated = false;
            if (File.Exists(target.TargetFilePath))
            {
                fileCreated = true;
                File.Delete(target.TargetFilePath);
            }
            Assert.IsTrue(fileCreated);
        }

        /// <summary>
        ///A test for Resources
        ///</summary>
        [TestMethod()]
        public void ResourcesTest()
        {
            string sourceFilePath = this._sourceFilePath;
            string targetCulture = "en";
            bool useTranslationMemory = false;
            bool useGoogleTranslate = false;
            ResourceGenerator target = new ResourceGenerator(sourceFilePath, targetCulture, useTranslationMemory, useGoogleTranslate); // TODO: Initialize to an appropriate value
            DataTable actual;
            actual = target.Resources;
            Assert.IsFalse(actual == null);
        }

        /// <summary>
        ///A test for TargetFilePath
        ///</summary>
        [TestMethod()]
        public void TargetFilePathTest()
        {
            string sourceFilePath = this._sourceFilePath;
            string targetCulture = "en";
            bool useTranslationMemory = false;
            bool useGoogleTranslate = false;
            ResourceGenerator target = new ResourceGenerator(sourceFilePath, targetCulture, useTranslationMemory, useGoogleTranslate); // TODO: Initialize to an appropriate value
            string actual;
            actual = target.TargetFilePath;
            Assert.IsTrue(actual == this._targetFilePath);
        }
    }
}
